package com.chuangke.file.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.chuangke.common.http.HttpResult;
import com.chuangke.file.model.SysFileShare;
import com.chuangke.file.service.SysFileShareService;

/**
 * 文档链接分享Controller
 * 
 * @author chuangke
 * @date "2020-09-08"
 */
@RestController
@RequestMapping("/file/share")
public class SysFileShareController {
    
    @Autowired
    private SysFileShareService sysFileShareService;

    /**
     * 查询文档链接分享列表
     */
    @PreAuthorize("hasAuthority('login:action')")
    @GetMapping("/list")
    public HttpResult list(SysFileShare sysFileShare) {
        List<SysFileShare> list = sysFileShareService.selectSysFileShareList(sysFileShare);
        return HttpResult.ok(list);
    }

    /**
     * 新增文档链接分享
     */
    @PreAuthorize("hasAuthority('login:action')")
    @PostMapping(value = "/save")
    public HttpResult save(@RequestBody SysFileShare sysFileShare) {
    	sysFileShareService.saveOrUpdateSysFileShare(sysFileShare);
        return HttpResult.ok();
    }

    /**
     * 删除文档链接分享
     */
    @PreAuthorize("hasAuthority('login:action')")
	@PostMapping("/remove")
    public HttpResult remove(@RequestBody List<String> ids) {
    	sysFileShareService.deleteSysFileShareByIds(ids);
        return HttpResult.ok();
    }
}
